import sys
from xml.sax import make_parser
from xml.sax import handler

class SimpleHandler(handler.ContentHandler):
    def startElement(self,name,attrs):
        print "Start: ",name
        for aname in attrs.getNames():
            print "        attribute : %s = %s" % (aname,attrs.getValue(aname))
    def endElement(self,name):
        print "End: ",name
    def characters(self,data):
        print "characters: ", data
        
class SimpleDTDHandler(handler.DTDHandler):
    def notationDecl(self,name,publicid,systemid):
        print "Notation: ", name,publicid,systemid
    def unparsedEntityDecl(self,name,publicid,systemid,ndata):
        print "UnparsedEntity: ",name,publicid,systemid,ndata
        
p = make_parser()
p.setContentHandler(SimpleHandler())
p.setDTDHandler(SimpleDTDHandler())

#p.parse(sys.argv[1])
p.parse("HSTPRs_v35.kml")
